home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / progs / editor / frexxed / bin / barfly2msg.c < prev    next >
C/C++ Source or Header  |  1993-03-29  |  4KB  |  124 lines

  1. /*************************************************************************
  2.  *
  3.  * Barfly2Msg.c
  4.  *
  5.  * by Bjorn Reese (breese@imada.ou.dk)
  6.  *
  7.  * Compiled with:
  8.  *   sc LINK OPT SMALLCODE SMALLDATA PARM=R STRIPDBG AUTOREG Barfly2Msg
  9.  *
  10.  * From the document of TDS:
  11.  *
  12.  * `Converter'
  13.  *      Use these gadgets to select the converter program for the
  14.  *      compiler/assembler. The purpose of the converter is to translate
  15.  *      the error messages coming from the compiler/assembler into a format
  16.  *      readable by the editor. The list gadget displays all converters
  17.  *      which are available in the directory `TDS:converters'. If you want
  18.  *      to use a compiler which doesn't have a converter, you can easily
  19.  *      write your own one. All the converter has to do is to read from
  20.  *      standard input the output of the compiler and to write to standard
  21.  *      output the error messages with the following format:
  22.  *
  23.  *           MyConverter <compiler_error_file >ted_error_file source_file
  24.  *
  25.  *           `<test.c> 10 E <Error Message>' for an error
  26.  *           `<test.c> 21 W <Error Message>' for a warning
  27.  *
  28.  *           where
  29.  *           <test.c>        : source file
  30.  *           10              : line
  31.  *           E or W          : error or warning
  32.  *           <Error Message> : error message
  33.  *
  34.  *      The converter program also receives the name of the source file as
  35.  *      the first argument on the command line which sometimes is very
  36.  *      helpful if the compiler didn't write the name of the source file
  37.  *      when outputing the error messages.
  38.  *
  39.  ************************************************************************/
  40.  
  41. /*************************************************************************
  42.  
  43. Error in Line 6 in a:a/err.asm.
  44. Error 8: MC680xx doesn't allow this command, adressmode or width.
  45.         mulu.l  d0,d0
  46.                      ^
  47.  
  48. Warning in Line 7 in test.asm.
  49. Warning 541: You use a supervisor command.
  50.     reset
  51.          ^
  52.  
  53. *** Unsupported
  54.  
  55. Error, Line 0 in Macro `FUNCDEF    SetRPAttrsA'.
  56. Macro is located at Line 179 in `INCLUDE    offset/graphics_lib.i    ;  forget. You can make them'
  57. Error 2: ATTENTION » NOT ENOUGH MEMORY «
  58.     FUNCDEF    SetRPAttrsA
  59.  
  60.  
  61. *************************************************************************/
  62.  
  63.  
  64. #include <stdio.h>
  65. #include <stdlib.h>
  66. #include <string.h>
  67.  
  68. #define MAXLINE 256
  69.  
  70. char *GetSource(char *text) {
  71.  
  72.    int i, j;
  73.  
  74.    /* skip initial text and search for "in" */
  75.    for(i=14; text[i] != 'i'; i++);
  76.    i +=3;
  77.    for(j = i; text[j] != '\n'; j++);
  78.    text[--j] = '\0';
  79.  
  80.    return &text[i];
  81. }
  82.  
  83.  
  84. void GetErrorMsg(char *text) {
  85.  
  86.    int i;
  87.  
  88.    fgets(text, MAXLINE, stdin);
  89.    for(i=0; text[i] != '\n'; i++);
  90.    text[i] = '\0';
  91. }
  92.  
  93.  
  94. void main(int argc, char *argv[]) {
  95.  
  96.    char text[MAXLINE], errmsg[MAXLINE], *source;
  97.    int line;
  98.  
  99.    while (fgets(text, MAXLINE, stdin) != NULL) {
  100.  
  101.       if (strncmp(text, "Error in", 8) == 0) {
  102.  
  103.          source = GetSource(text);
  104.          line = atoi(&text[14]);
  105.          GetErrorMsg(errmsg);
  106.  
  107.          fprintf(stdout, "<%s> %d E <%s>\n", source, line, errmsg);
  108.       } else {
  109.          if (strncmp(text, "Warning in", 10) == 0) {
  110.  
  111.             source = GetSource(text);
  112.             line = atoi(&text[16]);
  113.             GetErrorMsg(errmsg);
  114.  
  115.             fprintf(stdout, "<%s> %d W <%s>\n", source, line, errmsg);
  116.          } else {
  117.             if (strncmp(text, "Error, Line", 11) == 0)
  118.                fprintf(stdout, "<> 0 E <Unsupported error. Check Error File>");
  119.          }
  120.       }
  121.    }
  122.  
  123. } /* main */
  124.